package com.gbei.center.oauth.req;

import com.gbei.center.enums.WaterMachineType;
import com.gbei.center.req.open.ReqCommon;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.ToString;
import org.hibernate.validator.constraints.Length;
import org.hibernate.validator.constraints.NotBlank;

import javax.validation.constraints.Max;
import javax.validation.constraints.Min;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Pattern;
import java.io.Serializable;

/**
 * 水机下单请求参数
 *
 * @author lixuzhou@foxmail.com
 * @version 0.1 2018/11/5
 */
@Data
@ToString(callSuper = true)
@ApiModel(value = "水机下单请求参数")
public class ReqPlaceOrder extends ReqCommon implements Serializable {

  private static final long serialVersionUID = 3143218051965457407L;

  @ApiModelProperty(value = "运营区域ID", required = true, example = "440305")
  @NotNull(message = "areaId不能为空")
  @Pattern(regexp = "^\\d{5}[1-9]$")
  private String areaId;

  @ApiModelProperty(value = "水机版本：STORE_A-商户版-按量结算 OFFICE_A-行政版A-按量结算", required = true, example = "STORE_A")
  @NotNull(message = "waterMachineType不能为空")
  private WaterMachineType waterMachineType;

  @ApiModelProperty(value = "结算类型：0-所有 1-京贝尔渠道代理商+WECAN基本", hidden = true)
  @Min(0)
  @Max(1)
  private Integer settleType = 1;

  @ApiModelProperty(value = "水机运营商openId", example = "a63511bff6308da39b97d9712eaeeefd")
  private String areaOperatorOpenId;

  @ApiModelProperty(value = "水机商户openId", example = "a63511bff6308da39b97d9712eaeeefd")
  private String areaMerchantOpenId;

  @ApiModelProperty(value = "水机机主openId", example = "a63511bff6308da39b97d9712eaeeefd")
  private String areaOwnerOpenId;

  @ApiModelProperty(value = "第三方应用生成的订单ID", required = true, example = "SJ_XXXX_0001")
  @NotBlank(message = "openAppOrderId不能为空")
  @Length(min=8, max=32)
  private String openAppOrderId;

  @ApiModelProperty(value = "订单金额（单位：分），单笔订单不小于100元，即该值不小于10000", required = true, example = "10000")
  @NotNull(message = "orderAmount不能为空")
  private Long orderAmount;

  public String getAreaId12() {
    return areaId + "000000";
  }
}
